package com.yto.hrreport.event.buttons {
	import com.yto.hrreport.command.ReportCommand;
	import com.yto.hrreport.event.buttons.superbutton.ButtonEvent;
	
	import flash.events.Event;
	
	import mx.controls.Button;
	
	public class CardListButtonEvent extends ButtonEvent {
		
		private static var cardListEvent : CardListButtonEvent = new CardListButtonEvent();
		
		private static var parentName : String;
		
		private var param : Object;
		
		public function CardListButtonEvent() {
			super();
		}
		
		public static function getInstance(parentName : String) : CardListButtonEvent {
			CardListButtonEvent.parentName = parentName;
			return cardListEvent
		}
		
		public function cardListHandler(event : Event) : void {
			
			param = ReportCommand.getInstance(parentName).initParam("onBoCard");
			
			var cardText : String = Button(param.headCanvas.getChildByName(parentName + "_btnCard")).label;
			
			if(cardText == "卡片界面") {
				
				Button(param.headCanvas.getChildByName(parentName + "_btnCard")).label = "列表界面";
				
				param.headGrid.visible = false;
				param.bodyGrid.top = 5;
				
				if(param.parentCanvas.getChildByName(parentName + "_headCard") == null) {
					ReportCommand.getInstance(parentName).createHeadCard(param.parentCanvas);
				} else 
					param.parentCanvas.getChildByName(parentName + "_headCard").visible = true;
				
				updateButtons(event , "card" , param.headCanvas , true);
				
			} else {
				
				Button(param.headCanvas.getChildByName(parentName + "_btnCard")).label = "卡片界面";
				
				param.headGrid.visible = true;
				param.bodyGrid.top = null;
				param.parentCanvas.getChildByName(parentName + "_headCard").visible = false;
				
				updateButtons(event , "list" , param.headCanvas , true);
			}
		}
	}
}